package com.liuzu.esys.listener;

import com.alibaba.excel.context.AnalysisContext;
import com.alibaba.excel.event.AnalysisEventListener;


import com.liuzu.esys.bo.AftersaleBo;
import com.liuzu.esys.pojo.Aftersale;
import com.liuzu.esys.service.AftersaleService;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;

/**
 * @date 2022/7/21
 * @desc
 */
@Component
@Scope("prototype")     // 注意 这里要设置成多例模式
public class WebAftersaleListener extends AnalysisEventListener<AftersaleBo> {
    @Autowired
    private AftersaleService aftersaleService;

    @Override
    public void invoke(AftersaleBo data, AnalysisContext analysisContext) {
        Aftersale aftersale = new Aftersale();
        BeanUtils.copyProperties(data,aftersale);
        aftersaleService.addAftersale(aftersale);
    }

    @Override
    public void doAfterAllAnalysed(AnalysisContext analysisContext) {

    }
}
